package edu.tcc.iot.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Configuration {
	
	private Properties applicationProperties;
	private static Configuration INSTANCE = new Configuration();
	
	private Configuration() {
		this.load();
	}
	
	public static Configuration getInstance(){
		return INSTANCE;
	}
	
	private void load() {
		try {
			applicationProperties = new Properties();
			InputStream in = new FileInputStream(new File("conf/Application.properties"));
			applicationProperties.load(in);
			in.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public String getProperty(String key){
		return applicationProperties.getProperty(key);
	}

	public int getInt(String key) {
		return Integer.parseInt(getProperty(key));
	}
}
